/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tpgen.patterns;

import java.util.Iterator;
import java.util.Set;
import tpgen.grammar.Variable;

/**
 *
 * @author shanki
 */
public class OntologyPattern implements Iterable<Axiom> {
    private Axioms axioms;
    
    public OntologyPattern() {
        axioms          = new Axioms();
    }
    
    public OntologyPattern(Axioms axioms) {
        this.axioms     = axioms;
    }
    
    public void add(Axiom axiom) {
        axioms.add(axiom);
    }

    public Axiom get(int index) {
        return axioms.get(index);
    }
    
    public int size() {
        return axioms.size();
    }    
    
    public Set<Variable> getVars() {
        return axioms.getVariables();
    }
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        
        sb.append("    <entity_declarations>\n");
        
        for (Variable variable : axioms.getVariables()) {
            sb.append("      <placeholder type=\"");
            sb.append(variable.getType().toString());
            sb.append("\">");
            sb.append(variable.toString());
            sb.append("</placeholder>\n");
        }
        
        sb.append("    </entity_declarations>\n");
        
        sb.append("    <axioms>\n");
        
        for (Axiom axiom : axioms) {
            sb.append("      <axiom>");
            sb.append(axiom.toString());
            sb.append("</axiom>\n");
        }
        
        sb.append("    </axioms>\n");
        
        return sb.toString();
    }

    @Override
    public Iterator<Axiom> iterator() {
        return axioms.iterator();
    }
    
}
